<?php
######################################################################
# SmallNuke: Advanced Content Management System
# ============================================
# Copyright (c) 2004 by Sergey Vipolzov (info@smallnuke.com)
# http://smallnuke.com
# ============================================
# Developed from the PHP-Nuke 7.0
# Copyright (c) 2002 by Francisco Burzi
# http://phpnuke.org/
# ============================================
# This program is free software. You can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
######################################################################

if (eregi("block-Pages_Cat.php", $_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

?>
<Script Language=JavaScript>
function clickHandler()
{var targetId, srcElement, targetElement;
srcElement = window.event.srcElement;
if (srcElement.className == "Outline")
{targetId = srcElement.id + "details";
targetElement = document.all(targetId);
if (targetElement.style.display == "none")
{targetElement.style.display = "";}
else
{targetElement.style.display = "none";}}}
document.onclick = clickHandler;
</Script>
<?


global $prefix, $db, $themepath;

$images = "<img src=\"".$themepath."modules/Pages/images/minus.gif\">";
$images2 = "<img src=\"".$themepath."modules/Pages/images/plus.gif\">";
$content = "";
$sql = "SELECT cid, title FROM ".$prefix."_smallpages_categories where parentid=0 order by cid, parentid";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$cid = $row[cid];
$title = $row[title];
$num = $db->sql_numrows($db->sql_query("SELECT cid FROM ".$prefix."_smallpages_categories WHERE parentid='$cid' limit 1"));
if ($num == 0) {
   $content .= "$images <a Style=\"cursor: hand; TEXT-DECORATION: none;\" href=\"".$themepath."modules.php?name=Pages&amp;go=showcat&amp;cid=$cid\">$title</a><br>";
}
else {
$content .= "$images2 <a id=\"Out".$cid."\" class=\"Outline\" style=\"cursor: hand;\">$title</a>";
$content .="<div id=Out".$cid."details style=\"display:None; position:relative; left:9;\">";

$sql2 = "SELECT cid, title FROM ".$prefix."_smallpages_categories where parentid=$cid order by cid, parentid";
$result2 = $db->sql_query($sql2);
while ($row2 = $db->sql_fetchrow($result2)) {
$cid2 = $row2[cid];
$title2 = $row2[title];
$num2 = $db->sql_numrows($db->sql_query("SELECT cid FROM ".$prefix."_smallpages_categories WHERE parentid='$cid2' limit 1"));
if ($num2 == 0) {
   $content .= "$images <a Style=\"cursor: hand; TEXT-DECORATION: none;\" href=\"".$themepath."modules.php?name=Pages&amp;go=showcat&amp;cid=$cid2\">$title2</a><br>";
}
else {
$content .= "$images2 <a id=\"Out".$cid2."\" class=\"Outline\" style=\"cursor: hand;\">$title2</a>";
$content .="<div id=Out".$cid2."details style=\"display:None; position:relative; left:9;\">";

$sql3 = "SELECT cid, title FROM ".$prefix."_smallpages_categories where parentid=$cid2 order by cid, parentid";
$result3 = $db->sql_query($sql3);
while ($row3 = $db->sql_fetchrow($result3)) {
$cid3 = $row3[cid];
$title3 = $row3[title];
$num3 = $db->sql_numrows($db->sql_query("SELECT cid FROM ".$prefix."_smallpages_categories WHERE parentid='$cid3' limit 1"));
if ($num3 > 0) { $c_links = "cat";  $c_img = "$images2"; }
else { $c_links = "showcat";  $c_img = "$images"; }
$content .= "$c_img <a Style=\"cursor: hand; TEXT-DECORATION: none;\" href=\"".$themepath."modules.php?name=Pages&amp;go=$c_links&amp;cid=$cid3\">$title3</a><br>";
}
$content .= "</div><br>";
}
}
$content .= "</div><br>";
}
}

?>
